﻿using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using System;
using System.Collections.Generic;

namespace Sustainalytics.Entities
{
    public class News : IEntity
    {
        public Guid Id { get; set; }

        public string Title { get; set; }

        public string TitleLowercase
        {
            get { return this.Title == null ? null : this.Title.ToLowerInvariant(); }
            set { }
        }

        public string Body { get; set; }

        public Guid AddedByUserId { get; set; }

        public string AddedByUserName { get; set; }
        public string AddedByUserNameLoweCase { get; set; }

        public NewsAvailability AvailableFor { get; set; }
        public string AvailableForText { get { return this.AvailableFor.ToString(); } set { } }
        public string AvailableForTextLowercase { get { return this.AvailableForText.ToLowerInvariant(); } set { } }

        [BsonRepresentation(BsonType.String)]
        public NewsStatus Status { get; set; }
        public string StatusText { get { return this.Status.ToString(); } set { } }
        public string StatusTextLowercase { get { return this.StatusText.ToLowerInvariant(); } set { } }

        [BsonRepresentation(BsonType.String)]
        public NewsCategory? Category { get; set; }
        public string CategoryText { get { return this.Category.ToString(); } set { } }
        public string CategoryTextLowercase { get { return this.CategoryText.ToLowerInvariant(); } set { } }

        public DateTime DateCreated { get; set; }

        public DateTime? UnpublishedDate { get; set; }

        public List<NewsTag> Tags { get; set; }

        [BsonRepresentation(BsonType.String)]
        public NewsRegion Region { get; set; }
        public string RegionText { get { return this.Region.ToString(); } set { } }
        public string RegionTextLowercase { get { return this.RegionText.ToLowerInvariant(); } set { } }


        /// <summary>
        /// Ctor.
        /// </summary>
        public News()
        {
            this.Tags = new List<NewsTag>();
        }
    }
}
